package com.szcatic.ework.utils;

import java.sql.Connection;
import java.sql.DriverManager;

/**
 * DB公共类
 * @author Administrator
 *
 */
public class DBUtils {
	
	private static String url = "jdbc:mysql://192.168.70.128:3306/ework?useSSL=false";
	
	private static String userName ="root";
	
	private static String password = "0000";
	
	private static String driverClass="com.mysql.cj.jdbc.Driver";
	/**
	 * 获得连接
	 * @return
	 */
	public static Connection getConnection() throws Exception{
		Class.forName(driverClass);
		return DriverManager.getConnection(url, userName, password);
	}
	
	/**
	 * 关闭连接
	 * @param con
	 * @throws Exception
	 */
	public static void closeConnection(Connection con) throws Exception {
		if (con != null) {
			con.close();
		}
	}

	public static void main(String[] args) {
		try {
			DBUtils.getConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
}
